/*
 * Copyright (c) 2021 Futurewei Technologies, Inc.
 *
 * clang2mpl is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PSL v2. You may obtain a copy of Mulan PSL v2 at:
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
 * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the
 * Mulan PSL v2 for more details.
 */
// RUN: %clang2mpl --ascii --verify %s -- -Wno-unused-value --target=aarch64-linux-elf
// RUN: cat %m | %FileCheck %s

void returnVoid() {
  // CHECK: LOC 2 [[#SLINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: return ()
  return;
}

int returnLiteral() {
  // CHECK: LOC 2 [[#SLINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: return (constval i32 1)
  return 1;
}

int returnVar(int x) {// CHECK: LOC 2 [[#SLINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: return (dread i32 %x)
  return x;
}

struct Small {
  int a;
  int b;
};

struct Small returnSmallStruct() {
  struct Small s;
  // CHECK: LOC 2 [[#SLINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: return (dread agg %s)
  return s;
}

struct Large {
  int a[16];
};

struct Large returnLargeStruct() {
  struct Large l;
  // CHECK: LOC 2 [[#SLINE: @LINE + 3 ]]{{$}}
  // CHECK-NEXT: iassign <* <$Large>> 0 (dread a64 %retval.0, dread agg %l)
  // CHECK-NEXT: return ()
  return l;
}
